import {
	http,
	Method
} from "@/utils/request.js";

import api from "@/config/api.js";


/**
 * 根据获取帖子
 * @param 
 */
export function getCircle(params) {
	return http.request({
		url: '/posts',
		method: Method.GET,
		params
	});
}

/**
 * 获取帖子详情
 * @param 
 */
export function getCircleInfo(id) {
	return http.request({
		url: `/posts/${id}`,
		method: Method.GET,
	});
}

/**
 * 发布圈子
 * @param 
 */
export function addNormal(params) {
	return http.request({
		url: '/posts',
		method: Method.POST,
		data: params
	});
}



/**
 * 发布评论
 * @param 
 */
export function addComment(params) {
	return http.request({
		url: '/comments',
		method: Method.POST,
		data: params
	});
}

// likeCircleInfo

/**
 * 点赞
 * @param 
 */
export function likeCircleInfo(id) {
	return http.request({
		url: `/posts/${id}/like`,
		method: Method.POST,
	});
}
/**
 * 取消点赞
 * @param 
 */
export function unlikeCircleInfo(id) {
	return http.request({
		url: `/posts/${id}/unlike`,
		method: Method.POST,
	});
}

/**
 * 删除帖子
 * @param 
 */
export function deleteCircle(id) {
	return http.request({
		url: `/posts/${id}`,
		method: Method.DELETE,
	});
}



/**
 * 编辑帖子
 * @param 
 */
export function editNormal(params) {
	return http.request({
		url: `/posts/${params.id}`,
		method: Method.PUT,
		data: params.data
	});
}


/**
 * 删除评论
 * @param 
 */
export function deleteComment(id) {
	return http.request({
		url: `/comments/${id}`,
		method: Method.DELETE,
	});
}

/**
 * 获取评论列表
 * @param {string} circleId - 帖子ID
 */
export function getComments(circleId) {
	return http.request({
		url: `/posts/${circleId}/comments`,
		method: Method.GET,
	});
}

/**
 * 点赞评论
 * @param {string} commentId - 评论ID
 */
export function likeComment(commentId) {
	return http.request({
		url: `/comments/${commentId}/like`,
		method: Method.POST,
	});
}

/**
 * 取消点赞评论
 * @param {string} commentId - 评论ID
 */
export function unlikeComment(commentId) {
	return http.request({
		url: `/comments/${commentId}/unlike`,
		method: Method.POST,
	});
}